#include <cstdio>

using namespace std;

class Clock
{
	public:
		int hour, minute, second;

		Clock(int _hour=0, int _minute=0, int _second=0)
		{
			hour = _hour;  // R
			minute = _minute;  // 0 ~ 59
			second = _second;  // 0 ~ 59
		}

		void print()
		{
			printf("%8d:%02d:%02d\n", hour, minute, second);
		}

		Clock operator+(const Clock& clock)
		{
			int s = second + clock.second;  // 0 ~ 118
			int m = minute + clock.minute;  // 0 ~ 118
			int h = hour + clock.hour;  // R
			// s -> m
			if (s > 59)
			{
				s -= 60;
				m += 1;
			}
			// m -> h
			if (m > 59)
			{
				m -= 60;
				h += 1;
			}
			return Clock(h, m, s);
		}

		Clock operator-(const Clock& clock)
		{
			int s = second - clock.second;  // -59 ~ 59
			int m = minute - clock.minute;  // -59 ~ 59
			int h = hour - clock.hour;  // R
			// s -> m
			if (s < 0)
			{
				s += 60;
				m -= 1;
			}
			// m -> h
			if (m < 0)
			{
				m += 60;
				h -= 1;
			}
			return Clock(h, m, s);
		}

		// ++prefix
		Clock operator++()
		{
			second += 1;
			// s -> m
			if (second > 59)
			{
				second -= 60;
				minute += 1;
			}
			// m -> h
			if (minute > 59)
			{
				minute -= 60;
				hour += 1;
			}
			return Clock(*this);
		}

		// postfix++  [Extra parameter of postfix 'operator++' must be of type 'int'.]
		Clock operator++(int)
		{
			Clock rtn(*this);
			second += 1;
			// s -> m
			if (second > 59)
			{
				second -= 60;
				minute += 1;
			}
			// m -> h
			if (minute > 59)
			{
				minute -= 60;
				hour += 1;
			}
			return rtn;
		}

		// --prefix
		Clock operator--()
		{
			second -= 1;
			// s -> m
			if (second < 0)
			{
				second += 60;
				minute -= 1;
			}
			// m -> h
			if (minute < 0)
			{
				minute += 60;
				hour -= 1;
			}
			return Clock(*this);
		}

		// postfix--  [Extra parameter of postfix 'operator-- must be of type 'int'.]
		Clock operator--(int)
		{
			Clock rtn(*this);
			second -= 1;
			// s -> m
			if (second < 0)
			{
				second += 60;
				minute -= 1;
			}
			// m -> h
			if (minute < 0)
			{
				minute += 60;
				hour -= 1;
			}
			return rtn;
		}
};

int main()
{
	Clock clock(12, 0, 0);
	clock.print();  // 12:00:00
	clock++.print();  // 12:00:00
	clock.print();  // 12:00:01
	clock--.print();  // 12:00:01
	clock.print();  // 12:00:00
	(--clock).print();  // 11:59:59
	clock.print();  // 11:59:59
	(++clock).print();  // 12:00:00
	clock.print();  // 12:00:00

	Clock c1(12, 40, 30), c2(0, 50, 30);
	(c1 + c2).print();  // 13:31:00
	(c1 - c2).print();  // 11:50:00

	return 0;
}
